﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="CustomerContactSystem.Core" namespace="CustomerContactSystem.Core.Model">
  <class name="User" table="Users">
    <id name="Id">
      <generator class="native" />
    </id>
    <many-to-one name="Department" class="Department" column="DepartmentId"  not-null="true" lazy="false" fetch="join" foreign-key="FK_Users_Departments"></many-to-one>
    <many-to-one name="UserGroup" class="UserGroup" column="GroupId"  not-null="true" lazy="false" fetch="join" foreign-key="FK_Users_UserGroups"></many-to-one>
    <property name="Username" not-null="true" length="20" />
    <property name="Password" not-null="true" length="20" />
    <property name="Email" not-null="true" length="250" />
    <property name="DisplayName" not-null="true" length="100" />
    <property name="FirstPointOfContact" not-null="true" />
    <property name="AreaCovered" not-null="true" length="100" />
    <property name="IsActive" not-null="true" />
    <set name="Roles" table="UsersRoles" access="field.camelcase-underscore" cascade="none" batch-size="50">
      <key column="UserId" foreign-key="FK_UsersRoles_Users"></key>
      <many-to-many column="RoleId" class="UserRole" foreign-key="FK_UsersRoles_UserRoles"/>
    </set>
  </class>
</hibernate-mapping>